//
//  PersistenceViewController.m
//  BaseTools
//
//  Created by 李挺哲 on 15/12/9.
//  Copyright © 2015年 ltz. All rights reserved.
//

#import "PersistenceViewController.h"
#import "FmdbViewController.h"
#import "BaseSqlViewController.h"
#import "CoreDataViewController.h"
#import "ArchiveViewController.h"
@interface PersistenceViewController ()
{
    NSMutableArray *array;
    BaseSqlViewController *baseSqlViewController;
    FmdbViewController * fmdbVc;
    CoreDataViewController *coreDataVc;
    ArchiveViewController * archiverVc;
    
}
@end

@implementation PersistenceViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    array=[NSMutableArray array];
    [array addObject:@"sqllite通讯录"];
    [array addObject:@"FMDBsqllite"];
    [array addObject:@"coreData"];
    [array addObject:@"归档"];
    fmdbVc=[[FmdbViewController alloc] init];
    baseSqlViewController=[[BaseSqlViewController alloc] init];
    coreDataVc=[[CoreDataViewController alloc] init];
    archiverVc=[[ArchiveViewController alloc] init];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    
    return 1;
    
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    
    return array.count;
    
}


-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *reuseId = @"NetWorkTableViewCell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:reuseId];
    if (cell == nil) {
        cell=[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseId];
    }
    cell.textLabel.textAlignment=NSTextAlignmentCenter;
    cell.textLabel.text=array[indexPath.row];
    return cell;
    
    
    
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    switch (indexPath.row) {
        case 0:
            [self showViewController:baseSqlViewController sender:self];

            break;
            
        case 1:
            [self showViewController:fmdbVc sender:self];

            break;
        case 2:
            
            [self showViewController:coreDataVc sender:self];

            break;
            
        case 3:
            [self showViewController:archiverVc sender:self];

            break;
            
            
        default:
            
            break;
    }
    
}


@end
